import 'package:flutter_elf/utils/get_utils.dart';
import 'package:flutter_hls_parser/flutter_hls_parser.dart';

import 'download/file_utils.dart';

/// CreateTime 2020/7/9 9:42
/// CreateUser chen 
/// ProjectName flutter_elf

void main()async{
  String contentString = '''
#EXTM3U
#EXT-X-STREAM-INF:PROGRAM-ID=1,BANDWIDTH=1000000,RESOLUTION=720x406
1000kb/hls/index.m3u8
  ''';
  Uri playlistUri;
  var playList;
  List<String> lines;
  try {
    playList = await HlsPlaylistParser.create().parseString(playlistUri, contentString);
  } on ParserException catch (e) {
    print(e);
  }

  print(playList);
  if (playList is HlsMasterPlaylist) {
    print("Master"+playList.mediaPlaylistUrls[0].toString());
    // master m3u8 file
  } else if (playList is HlsMediaPlaylist) {
    print("Media"+playList.toString());
    print(playList.segments[0].url);
    // media m3u8 file
  }
  await Future.delayed(Duration(seconds: 2));
}